Overview | Package | Class | Tree | Deprecated | Index | Help |
Java Platform 1.1.7 |
||
PREV CLASS | NEXT CLASS | FRAMES | NO FRAMES | ||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Component | +--java.awt.Container | +--com.sun.java.swing.JComponent | +--com.sun.java.swing.JComboBox
For the keyboard keys used by this component in the standard Look and Feel (L&F) renditions, see the JComboBox key assignments.
Warning: serialized objects of this class will not be compatible with future swing releases. The current serialization support is appropriate for short term storage or RMI between Swing1.0 applications. It will not be possible to load serialized Swing1.0 objects with future releases of Swing. The JDK1.2 release of Swing will be the compatibility baseline for the serialized form of Swing objects.
Inner Class Summary | |
JComboBox.AccessibleJComboBox
The class used to obtain the accessible role for this object. |
|
static | JComboBox.KeySelectionManager
The interface that defines a KeySelectionManager. |
Inner classes inherited from class com.sun.java.swing.JComponent | |
JComponent.AccessibleJComponent |
Field Summary | |
java.lang.String | actionCommand
|
ComboBoxModel | dataModel
|
ComboBoxEditor | editor
|
boolean | isEditable
|
JComboBox.KeySelectionManager | keySelectionManager
|
boolean | lightWeightPopupEnabled
|
int | maximumRowCount
|
ListCellRenderer | renderer
|
java.lang.Object | selectedItemReminder
|
Fields inherited from class com.sun.java.swing.JComponent | |
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
Fields inherited from class java.awt.Component | |
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Constructor Summary | |
JComboBox(ComboBoxModel aModel)
Creates a JComboBox that takes its items from an existing ComboBoxDataModel. |
|
JComboBox(java.lang.Object[] items)
Creates a JComboBox that contains the elements in the specified array. |
|
JComboBox(java.util.Vector items)
Creates a JComboBox that contains the elements in the specified Vector. |
|
JComboBox()
Creates a JComboBox with a default data model. |
Method Summary | |
void | actionPerformed(java.awt.event.ActionEvent e)
This method is public as an implementation side effect. do not call or override. |
void | addActionListener(java.awt.event.ActionListener l)
Adds an ActionListener. |
void | addItem(java.lang.Object anObject)
Adds an item to the item list. |
void | addItemListener(java.awt.event.ItemListener aListener)
Adds an ItemListener. |
void | configureEditor(ComboBoxEditor anEditor,
java.lang.Object anItem)
Initializes the editor with the specified item. |
void | contentsChanged(ListDataEvent e)
This method is public as an implementation side effect. do not call or override. |
JComboBox.KeySelectionManager | createDefaultKeySelectionManager()
Returns an instance of the default key-selection manager. |
void | fireActionEvent()
Notify all listeners that have registered interest for notification on this event type. |
void | fireItemStateChanged(java.awt.event.ItemEvent e)
Notify all listeners that have registered interest for notification on this event type. |
AccessibleContext | getAccessibleContext()
Get the AccessibleContext associated with this JComponent |
java.lang.String | getActionCommand()
Returns the action commnand that is included in the event sent to action listeners. |
ComboBoxEditor | getEditor()
Returns the editor used to paint and edit the selected item in the JComboBox field. |
java.lang.Object | getItemAt(int index)
Returns the list item at the specified index. |
int | getItemCount()
Returns the number of items in the list. |
JComboBox.KeySelectionManager | getKeySelectionManager()
Returns the list's key-selection manager. |
int | getMaximumRowCount()
Returns the maximum number of items the combo box can display without a scrollbar |
ComboBoxModel | getModel()
Returns the data model currently used by the JComboBox. |
ListCellRenderer | getRenderer()
Returns the renderer used to display the selected item in the JComboBox field. |
int | getSelectedIndex()
Returns the index of the currently selected item in the list. |
java.lang.Object | getSelectedItem()
Returns the currently selected item. |
java.lang.Object[] | getSelectedObjects()
Returns an array containing the selected item. |
java.lang.String | getUIClassID()
Returns the name of the L&F class that renders this component. |
com.sun.java.swing.plaf.ComboBoxUI | getUI()
Returns the L&F object that renders this component. |
void | hidePopup()
Causes the combo box to close its popup window |
void | insertItemAt(java.lang.Object anObject,
int index)
Inserts an item into the item list at a given index. |
void | installAncestorListener()
|
void | intervalAdded(ListDataEvent e)
Invoked items have been added to the internal data model. |
void | intervalRemoved(ListDataEvent e)
Invoked when values have been removed from the data model. |
boolean | isEditable()
Returns true if the JComboBox is editable. |
boolean | isFocusTraversable()
Returns true if the component can receive the focus. |
boolean | isLightWeightPopupEnabled()
Returns true if lightweight (all-Java) popups are in use, or false if heavyweight (native peer) popups are being used. |
boolean | isOpaque()
Returns true to indicate that this component paints every pixel in its range. |
void | processKeyEvent(java.awt.event.KeyEvent e)
Handles KeyEvents, looking for the Tab key. |
void | removeActionListener(java.awt.event.ActionListener l)
Removes an ActionListener |
void | removeAllItems()
Removes all items from the item list. |
void | removeItemAt(int anIndex)
Removes the item at anIndex
This method works only if the JComboBox uses the default data model.
|
void | removeItem(java.lang.Object anObject)
Removes an item from the item list. |
void | removeItemListener(java.awt.event.ItemListener aListener)
Removes an ItemListener |
void | selectedItemChanged()
This method is called when the selected item changes. |
boolean | selectWithKeyChar(char keyChar)
Selects the list item that correponds to the specified keyboard character and returns true, if there is an item corresponding to that character. |
void | setActionCommand(java.lang.String aCommand)
Sets the action commnand that should be included in the event sent to action listeners. |
void | setEditable(boolean aFlag)
Determines whether the JComboBox field is editable. |
void | setEditor(ComboBoxEditor anEditor)
Sets the editor used to paint and edit the selected item in the JComboBox field. |
void | setEnabled(boolean b)
Enables the combo box so that items can be selected. |
void | setKeySelectionManager(JComboBox.KeySelectionManager aManager)
Sets the object that translates a keyboard character into a list selection. |
void | setLightWeightPopupEnabled(boolean aFlag)
When displaying the popup, JComboBox choose to use a light weight popup if it fits. |
void | setMaximumRowCount(int count)
Sets the maximum number of rows the JComboBox displays. |
void | setModel(ComboBoxModel aModel)
Sets the data model that the JComboBox uses to obtain the list of items. |
void | setRenderer(ListCellRenderer aRenderer)
Sets the renderer that paints the item selected from the list in the JComboBox field. |
void | setSelectedIndex(int anIndex)
Selects the item at index anIndex . |
void | setSelectedItem(java.lang.Object anObject)
Sets the selected item in the JComboBox by specifying the object in the list. |
void | setUI(com.sun.java.swing.plaf.ComboBoxUI ui)
Sets the L&F object that renders this component. |
void | showPopup()
Causes the combo box to display its popup window |
void | updateUI()
Notification from the UIFactory that the L&F has changed. |
Methods inherited from class java.awt.Container | |
add, add, add, add, add, addContainerListener, addImpl, addNotify, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponentAt, getComponentAt, getComponent, getComponentCount, getComponents, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, paint, paramString, preferredSize, printComponents, print, processContainerEvent, processEvent, removeAll, remove, remove, removeContainerListener, removeNotify, setLayout, update, validate, validateTree |
Methods inherited from class java.awt.Component | |
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getName, getParent, getPeer, getPreferredSize, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paint, paramString, postEvent, preferredSize, prepareImage, prepareImage, printAll, print, processComponentEvent, processEvent, processFocusEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFont, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, update, validate |
Methods inherited from class java.lang.Object | |
clone, equals, finalize, getClass, hashCode, notifyAll, notify, toString, wait, wait, wait |
Field Detail |
protected ComboBoxModel dataModel
protected ListCellRenderer renderer
protected ComboBoxEditor editor
protected int maximumRowCount
protected boolean isEditable
protected java.lang.Object selectedItemReminder
protected JComboBox.KeySelectionManager keySelectionManager
protected java.lang.String actionCommand
protected boolean lightWeightPopupEnabled
Constructor Detail |
public JComboBox(ComboBoxModel aModel)
aModel
- the ComboBoxModel that provides the displayed list of itemspublic JComboBox(java.lang.Object[] items)
public JComboBox(java.util.Vector items)
public JComboBox()
addItem
to add items.Method Detail |
protected void installAncestorListener()
public void setUI(com.sun.java.swing.plaf.ComboBoxUI ui)
ui
- the ComboBoxUI L&F objectpublic void updateUI()
public java.lang.String getUIClassID()
public com.sun.java.swing.plaf.ComboBoxUI getUI()
public void setModel(ComboBoxModel aModel)
aModel
- the ComboBoxModel that provides the displayed list of itemspublic ComboBoxModel getModel()
public void setLightWeightPopupEnabled(boolean aFlag)
public boolean isLightWeightPopupEnabled()
public void setEditable(boolean aFlag)
aFlag
- a boolean value, where true indicates that the field is editablepublic boolean isEditable()
public void setMaximumRowCount(int count)
count
- an int specifying the maximum number of items to display
in the list before using a scrollbarpublic int getMaximumRowCount()
public void setRenderer(ListCellRenderer aRenderer)
The default renderer displays a string, obtained
by calling the selected object's toString
method.
Other renderers can handle graphic images and composite items.
To display the selected item, aRenderer.getListCellRendererComponent
is called, passing the list object and an index of -1.
aRenderer
- the ListCellRenderer that displays the selected item.public ListCellRenderer getRenderer()
public void setEditor(ComboBoxEditor anEditor)
anEditor
- the ComboBoxEditor that displays the selected itempublic ComboBoxEditor getEditor()
public void setSelectedItem(java.lang.Object anObject)
anObject
is in the list, the list displays with
anObject
selected. If the object does not exist in the list,
the default data model selects the first item in the list.
anObject
- the list object to selectpublic java.lang.Object getSelectedItem()
public void setSelectedIndex(int anIndex)
anIndex
.
anIndex
- an int specifying the list item to select, where 0 specifies
the first item in the listpublic int getSelectedIndex()
public void addItem(java.lang.Object anObject)
anObject
- the Object to add to the listpublic void insertItemAt(java.lang.Object anObject, int index)
anObject
- the Object to add to the list
index
- an int specifying the position at which to add the itempublic void removeItem(java.lang.Object anObject)
anObject
- the object to remove from the item listpublic void removeItemAt(int anIndex)
anIndex
This method works only if the JComboBox uses the default data model.
JComboBox uses the default data model when created with the
empty constructor and no other model has been set.
anIndex
- an int specifying the idex of the item to remove, where 0
indicates the first item in the listpublic void removeAllItems()
public void showPopup()
public void hidePopup()
public void addItemListener(java.awt.event.ItemListener aListener)
aListener
will receive an event when
the selected item changes.
aListener
- the ItemListener that is to be notifiedpublic void removeItemListener(java.awt.event.ItemListener aListener)
aListener
- the ItemListener to removepublic void addActionListener(java.awt.event.ActionListener l)
l
- the ActionListener that is to be notifiedpublic void removeActionListener(java.awt.event.ActionListener l)
l
- the ActionListener to removepublic void setActionCommand(java.lang.String aCommand)
aCommand
- a string containing the "command" that is sent
to action listeners. The same listener can then
do different things depending on the command it
receives.public java.lang.String getActionCommand()
protected void fireItemStateChanged(java.awt.event.ItemEvent e)
protected void fireActionEvent()
protected void selectedItemChanged()
public java.lang.Object[] getSelectedObjects()
public void actionPerformed(java.awt.event.ActionEvent e)
public void contentsChanged(ListDataEvent e)
public boolean selectWithKeyChar(char keyChar)
keyChar
- a char, typically this is a keyboard key typed by the userpublic void intervalAdded(ListDataEvent e)
public void intervalRemoved(ListDataEvent e)
public void setEnabled(boolean b)
b
- a boolean value, where true enables the component and
false disables itpublic void configureEditor(ComboBoxEditor anEditor, java.lang.Object anItem)
anEditor
- the ComboBoxEditor that displays the list item in the
combo box field and allows it to be edited
anItem
- the object to display and edit in the fieldpublic void processKeyEvent(java.awt.event.KeyEvent e)
e
- the KeyEvent containing the keyboard key that was pressedpublic boolean isFocusTraversable()
public void setKeySelectionManager(JComboBox.KeySelectionManager aManager)
public JComboBox.KeySelectionManager getKeySelectionManager()
public int getItemCount()
public java.lang.Object getItemAt(int index)
index
- an int indicating the list position, where the first
item starts at zeroprotected JComboBox.KeySelectionManager createDefaultKeySelectionManager()
public boolean isOpaque()
public AccessibleContext getAccessibleContext()
Overview | Package | Class | Tree | Deprecated | Index | Help |
Java Platform 1.1.7 |
||
PREV CLASS | NEXT CLASS | FRAMES | NO FRAMES | ||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |